/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
var backgroundImage = new Image();
backgroundImage.src = "img/asphalt.jpeg";
/**
 @param context kontekst graficzny kanwy
 */
function Scene(context)
{
//    this.Width=null;
//    this.Height=null;

    //<editor-fold defaultstate="collapsed" desc="fields">
    this.Context = context;
    this.EventManager = new inputEvents();
    this.EventManager.Init();
    this.maze;
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Draw Objects">
    this.frameNumber = 0;
    this.Objects = Array();
    this.addToScene = function(object) {
        this.Objects.push(object);
    };
    this.clearScene = function()
    {
        this.Objects = Array();
    };
    this.Draw = function()
    {
        this.Context.clearRect(0,0, this.Context.canvas.clientWidth, this.Context.canvas.clientHeight)
        
        this.Context.drawImage(backgroundImage, 0,0,1200,800);
        for (ob in this.Objects)
            this.Objects[ob].Draw(this.frameNumber);
        this.frameNumber++;
    };
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Camera">
    this.RotateAt = function(angle, X, Y)
    {
        c = this.Context;
        moveX = X;
        moveY = Y;
        c.translate(moveX, moveY);
        c.rotate(DegrestoRadians(angle));
        c.translate(-moveX, -moveY);
    };
    //</editor-fold>

    
    this.clearRect = function(x, y, width, height) {
        this.Context.clearRect(x, y, width, height);
    };
    this.fillRect = function(x, y, width, height) {
        this.Context.fillRect(x, y, width, height);
    };
    this.strokeRect = function(x, y, width, height) {
        this.Context.strokeRect(x, y, width, height);
    };
}
/*
 (\w*)$
 this.$1 = function (x,y,width,height) { this.Context.$1(x,y,width,height); }; 
 * 
 */


function DegrestoRadians(angle)
{
    return Math.PI * angle / 180;
}